//
//  UUHybridSelectCarHandler.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 23/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUHybridSelectCarHandler.h"
#import "UUCarPicker.h"
#import "UUCarManager.h"

@implementation UUHybridSelectCarHandler

- (NSString *)name {
    return @"selectCarNum";
}

- (void)executeWithParams:(id)params callbackWith:(void (^)(id))callback {
    NSNumber *fleetId = params[@"motorcade_id"];
    NSNumber *carCategory = [self.context.userInfo objectForKey:@"greaterThanOrEqualToCarCategory"];
    
    UIViewController *picker = [UUCarPicker pickerWithStatus:UUCarReviewStatusApproval
                                                     fleetId:fleetId
                             greaterThanOrEqualToCarCategory:carCategory
                                               completeBlock:^(id carId) {
                                                   callback(@{
                                                              @"bus_id" : carId,
                                                              @"bus_name" : [GetCarManager() fetchCarWithCarId:carId].carNum
                                                              });
                                               }];
    [self.context.hostVC presentViewController:picker animated:YES completion:nil];
}

@end
